<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 钉钉语音消息 v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace ding\msg\chat;

/**
 * 语音会话消息
 *
 * @package ding\msg\chat
 */
class VoiceChatMsg extends ChatMsg {
    protected $mediaId;
    protected $duration;

    /**
     * 语音消息构造函数
     *
     * @param $mediaId
     * @param int $duration 音频时长
     */
    public function __construct($mediaId, $duration = 60) {
        parent::__construct("voice");
        $this->mediaId = $mediaId;
        $this->duration = "" . $duration;
    }

    /**
     * 获取消息体
     * {
     *            "media_id": "mediaId",
     *            "duration": "10"
     * }
     * @return array
     */
    public function getMsgContent() {
        return [
            'media_id' => $this->mediaId,
            'duration' => $this->duration
        ];
    }

}
